


import java.util.ArrayList;
        import java.util.List;
        import java.util.Scanner;

class Main22{
    static int cnt = 0;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            int n = sc.nextInt();
            int[] W = new int[n];
            int[] T = new int[n];
            for(int i = 0; i < n; i++){
                W[i] = sc.nextInt();
            }
            for(int i = 0; i < n; i++){
                T[i] = sc.nextInt();
            }
            int mod = sc.nextInt();
            helper(W, T, new boolean[n], new ArrayList<Integer>());
            System.out.println(cnt % mod);
            cnt = 0;
        }
    }

    public static void helper(int[] W, int[] T, boolean[] visited, ArrayList<Integer> arr){
        if(W.length == arr.size()){
            int i;
            for(i = 0; i < W.length; i++){
                if(W[i]<arr.get(i)){
                    break;
                }
            }
            if(i==W.length){
                cnt++;
            }
            return;
        }

        for(int i = 0; i < W.length; i++){
            if(visited[i] == false){
                visited[i] = true;
                arr.add(T[i]);
                helper(W, T , visited, arr);
                visited[i] = false;
                arr.remove(arr.size()-1);
            }
        }
    }

}

